#include <dirent.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <fcntl.h>  
#include <netinet/in.h>
#include <getopt.h>
#include <netdb.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <pthread.h>
#define SERVER_PORT 12345
#define FILE_SIZE 500 
#define MAX_CONNETCION_COUNT 20
#define MAX_SENDLENGTH 100000
#define MAX_SIZE_OF_FILE_NAME 512
#define MAX_PORT_NUM 65535
#define BUFFER_SIZE 1024
#define DEBUG_LOG 0
#define SLEEPUS 1000
struct TCP_STRUCT_DATA
{
	int m_cmd;
	int m_data_len;
};

enum TCP_CMD
{
	GET_FILE = 0,
	GET_DIR = 1,
	//...
};
typedef struct CommandOpt
{
	char ip[30];
	int port;
	bool hidden;
	bool show;
	char outfilename[500];
	char sourcename[500];
}Opt, *Popt;
int judgefile(char * filepath);
long get_file_size(char *file_name);
int TraverseDir(char *direntName, int level, bool flag);
bool parseopt(int argc, char *argv[], Popt opt, struct option *long_options, char * shortopts, bool fserver);
bool is_ipv4_addr(char *ip);
int is_exist_file(char * filepath, char * filename);